import 'package:flutter/material.dart';
import 'package:get/get.dart';
import 'package:ljy_flutter/get/binding/binding_home_controller.dart';

class BHomeWidget extends StatelessWidget {
  const BHomeWidget({super.key});

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: const Text('Getx BHome'),
      ),
      body: Center(
        child: Column(
          mainAxisAlignment: MainAxisAlignment.center,
          crossAxisAlignment: CrossAxisAlignment.center,
          children: [
            Obx(() {
              final count = Get.find<BindingHomeController>().count;
              return Text('BHome 计数器 count: $count', style: const TextStyle(color: Colors.red, fontSize: 20));
            }),
            const SizedBox(height: 20,),
            ElevatedButton(onPressed: (){
              Get.find<BindingHomeController>().increment();
            }, child: const Text('BHome 增加计数器')),
            SizedBox(height: 20,),
            ElevatedButton(onPressed: () {
              Get.back();
            }, child: const Text('返回首页')),
          ],
        ),
      ),
    );
  }
}